<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8"%> 
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="page" uri="/WEB-INF/page"%>
<%@page isELIgnored="false"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>
    <link href="${pageContext.request.contextPath}/static/assets/css/bootstrap.css" rel="stylesheet" />
    <link href="${pageContext.request.contextPath}/static/assets/css/font-awesome.css" rel="stylesheet" />
    <link href="${pageContext.request.contextPath}/static/assets/css/custom-styles.css" rel="stylesheet" />
    <link href="${pageContext.request.contextPath}/static/assets/js/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
</head>
<body>
    <div id="wrapper">
        <div id="page-wrapper" >
          	<div id="page-inner">
			 	<div class="row">
                    <div class="col-md-12">
                        <h1 class="page-header">
                           	代金券 <small>management</small>
                        </h1>
                    </div>
              	</div>        
              	    
            	<div class="row">
                	<div class="col-md-12">
                    	<div class="panel panel-default">
                        	<div class="panel-heading">
                             		用户代金券
                        	</div>
                        	<form action="allowance" method="post" id="queryForm">
                        	<div>
                       			<p>
                       			 <span>用户编号：</span>
                       			 <span>
                       			 	${queryDto.userCode }
                       			 	<input type="hidden" name="userCode" value="${queryDto.userCode }"/>
                       			 </span>&nbsp&nbsp
                       			<shiro:hasPermission name="appuser:allowance:create"> 	
    							<%-- <button class="btn btn-primary" onclick="javascript:location.href='${pageContext.request.contextPath}/allowance/create?userCode=${queryDto.userCode }'">详情</button> --%>
    							 <a href="${pageContext.request.contextPath}/allowance/create?userCode=${queryDto.userCode }">新增代金券</a><br/>
						 	</shiro:hasPermission>
                       			</p>
                        	</div>                        	
                        	<!-- <shiro:hasPermission name="appuser:allowance:create"> 	
    							<button class="btn btn-primary" href="${pageContext.request.contextPath}/allowance/create?userCode=${queryDto.userCode }">详情</button>
    							 <a href="${pageContext.request.contextPath}/allowance/create?userCode=${queryDto.userCode }">新增代金券</a><br/>
						 	</shiro:hasPermission> -->
                      		<div class="panel-body">
                            	<div class="table-responsive">
                                	<table class="table table-striped table-bordered table-hover" id="dataTables-example">
	                                    <thead>
	                                        <tr>
	                                            <th>代金券名称</th>
	                                            <th>金额</th>
	                                            <th>有效期开始时间</th>
	                                            <th>有效期结束时间</th>
	                                            <th>代金券类型</th>
	                                            <th>录入时间</th>
                                     			<th>订单号</th> 
                                     			<th>使用时间</th> 
                                     			<th>状态</th> 
	                                            <th>详情</th>
	                                        </tr>
	                                    </thead>
                                    	<tbody>
		                                    <c:forEach items="${page.results}" var="ticket">
		                                        <tr class="odd gradeX">
		                                            <td class="center">${ticket.name}</td>
		                                            <td>${ticket.money}</td>
		                                            <td>
		                                            	${ticket.startTime }
		                                            </td>
		                                            <td>
		                                            	${ticket.expiryTime }
		                                            </td>
		                                            <td>
		                                            	<c:if test="${ticket.type == '0' }">
		                                            		现金券
		                                            	</c:if>
		                                            	<c:if test="${ticket.type == '1' }">
		                                            		折扣券
		                                            	</c:if>
		                                            </td>      
		                                            <td>
		                                            	${ticket.inputTime }
		                                            </td>   		  
		                                            <td>${ticket.orderCode}</td>	
		                                            <td>
		                                            	<fmt:formatDate value="${ticket.useTime }" pattern="yyyy-MM-dd HH:mm:ss"/>
		                                            </td> 	                                            
		                                            <td>
		                                            	<c:if test="${ticket.state == 0 }">
		                                            		未使用
		                                            	</c:if>
		                                            	<c:if test="${ticket.state == 1 }">
		                                            		已使用
		                                            	</c:if>
		                                            </td>
		                                            <td >
		                                            	<shiro:hasPermission name="appuser:allowance:update">   
                        									<a href="${pageContext.request.contextPath}/allowance/${ticket.id}/update">修改</a>
                    							 		</shiro:hasPermission>
								                       	<shiro:hasPermission name="appuser:allowancence:delete"> 
								                        	<a href="${pageContext.request.contextPath}/allowance/${ticket.id}/delete">删除</a>
								                  		</shiro:hasPermission>  
								                  	</td>
		                                        </tr>
		                                     </c:forEach>
                                    	</tbody>
                                	</table>
                            	</div>
                        	</div>
                        	<p align="right"><page:page page="${page }"/></p>
				            </form>
                    	</div>
                	</div>
				</div>
        	</div>
	    </div>
	</div>
    <script src="${pageContext.request.contextPath}/static/assets/js/jquery-1.10.2.js"></script>
    <script src="${pageContext.request.contextPath}/static/assets/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/assets/js/jquery.metisMenu.js"></script>
    <script src="${pageContext.request.contextPath}/static/assets/js/dataTables/jquery.dataTables.js"></script>
    <script src="${pageContext.request.contextPath}/static/assets/js/dataTables/dataTables.bootstrap.js"></script>
    <script src="${pageContext.request.contextPath}/static/assets/js/morris/morris.js"></script>
    <script src="${pageContext.request.contextPath}/static/assets/js/custom-scripts.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/page.js"></script>
    <script>
          $(document).ready(function () {

          });
  	</script>
</body>
</html>
